import request from '@/utils/request.js'
// import {useTokenStore} from '@/stores/token.js'
//文章分类列表查询
export const articleCategoryListService = () => {
    // const TokenStore = useTokenStore();
    //在pinia定义的响应式数据不用.value，直接使用
    // return request.get('/category',{headers:{'Authorization':TokenStore.token}});
    return request.get('/category');
}

export const ArticleCategoryAddService = (categoryData) => {

    return request.post('/category', categoryData);
}
//文章分类修改
export const ArticleCategoryUpdateService = (categoryData) => {
    return request.put('/category', categoryData);
}
//文章分类删除
export const ArticleCategoryDeleteService = (id) => {
    return request.delete('/category', { params: { id } });
}
//文章列表查询
export const articleListService = (params) => {
    return request.get('/article',{params:params})
}

//文章添加
export const ArticleAddService = (articleData) => {
    return request.post('/article',articleData);

}

// //文章列表查询(要求补全)
// export const ArticleListService = (pageNum, pageSize, categoryId = null, state = null) => {
//     // 构建请求参数，只包含非空的搜索条件
//   const params = {
//     pageNum,
//     pageSize,
//     ...(categoryId && { categoryId }),
//     ...(state && { state })
//   };
//     return request.get('/article',{params:})
// }